﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ChangePassword.aspx.cs" Inherits="ChangePassword" Title="猎书网-更改密码" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<script language="javascript" src="/model/jquery.validate.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){    
  $.validator.setDefaults({    
  submitHandler: function(form) { 
    $.ajax({ url: 'ChangePassword.aspx',
            type: 'POST',
            data: { lb: "change", oldpassword: $("#oldpassword").val(),password:$("#password").val()},
            dataType: 'html',
            timeout: 1000,
            error: function() { alert('未知错误'); },
            success: function(data) { 
                window.alert(data);
                if(data=="密码已修改")
                    window.location="/MyBook.aspx";       
            }
            }); 
    }    //end of submitHandler
  });  // end of setDefaults
  
  $(myForm).validate({    
/* 设置验证规则 */    
  rules: {    
   oldpassword:{
    required:true
   },  
   password: {    
    required: true,
    minlength:7
   },
   repassword: {    
    required: true,
    equalTo: "#password"
   }
  },    
/* 设置错误信息 */    
  messages: {    
   oldpassword:{
    required:"请填写旧密码"
   },  
   password: {    
    required: "请填写新密码",
    minlength:jQuery.format("密码不得小于{0}位.")
   },
   repassword: {    
    required: "请再次输入",
    equalTo: "两次密码输入不相同"    
   }
  },    
/* 错误信息的显示位置 */    
  errorPlacement: function(error, element) {    
    error.appendTo( element.parent() );      
  },    
  success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		  }
  });
}); 
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="myForm" action="#">
  <table cellspacing="0" cellpadding="0" class="myTable myFormTable">
    <tr>
      <td colspan="2" class="title">更改密码</td>
    </tr>
    <tr>
      <th width="25%">旧密码：</th>
      <td width="75%"><input name="oldpassword" type="password" id="oldpassword" /></td>
    </tr>
    <tr>
      <th>新密码：</th>
      <td><input name="password" type="password" id="password" /></td>
    </tr>
    <tr>
      <th>再一次：</th>
      <td><input name="repassword" type="password" id="repassword" /></td>
    </tr>
  </table>
  <div><input type="submit" name="change" value="更改" id="change"/></div>
</form>
</asp:Content>

